class MusicPlayer:
    instance = None

    init_flag = True

    def __new__(cls, *args, **kwargs):
        """如果类属性instance是None 那么就调用父类的new方法为这个类变量赋值，否则直接返回上次的赋值"""
        if MusicPlayer.instance is None:
            return super().__new__(cls)

    def __init__(self):
        if MusicPlayer.init_flag:
            print('如果是false证明没有执行过，那么执行一次')
            MusicPlayer.init_flag = False


if __name__ == '__main__':
    """多次调用返回的内存地址是一样的"""
    print(MusicPlayer())
    print(MusicPlayer())
    print(MusicPlayer())
